package com.qiaoba.auth.advice;


import com.qiaoba.common.base.entity.AjaxResult;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 全局异常处理
 *
 * @author ailanyin
 * @version 1.0
 * @since 2021/10/15 0015 下午 16:43
 */
@ControllerAdvice
public class SecurityExceptionAdvice {

    /**
     * 无权限异常
     *
     * @param e AccessDeniedException
     * @return AjaxResult
     */
    @ExceptionHandler({AccessDeniedException.class})
    @ResponseBody
    public AjaxResult handlerAccessDeniedException(AccessDeniedException e) {
        return AjaxResult.error("此接口无权限访问");
    }
}
